<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<link rel="icon" type="image/png" href="assets/img/favicon.ico">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

	<title>Light Bootstrap Dashboard by Creative Tim</title>

	<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
    <meta name="viewport" content="width=device-width" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/animate.min.css" rel="stylesheet"/>
    <link href="assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>
   <!--  <link href="assets/css/demo.css" rel="stylesheet" />
 -->
    
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/animate.min.css" rel="stylesheet"/>
    <link href="assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>

    <!--     Fonts and icons     -->
    <script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
    <link href="assets/css/pe-icon-7-stroke.css" rel="stylesheet" />

    
    <script type="text/javascript">
    
    $(function(){
    	
    	getTermList();
    	getTeacherList();
    	
        $("#show").on("click",function(){
        	getCourse();
            });
        function getTermList()
        {
        	$.ajax({
        		type:"GET",
        		url:"http://192.168.20.194:8080/sysedu/teacher",
        		data:{type:"getTermList"},
        		dataType:"json",
        		success:function(res)
        		{
        			var termList=res;
        			for(var i=0;i<termList.length;i++)
        			{
        				
        				var option=$("<option value="+termList[i].id+">"+termList[i].name+"</option>");
        				
        				option.appendTo($("#s_id"));
        			}
        			getCheckCode();
        		}
        		
        	});
        	
        }
        function getTeacherList()
        {
        	$.ajax({
        		type:"GET",
        		url:"http://192.168.20.194:8080/sysedu/teacher",
        		data:{type:"getTeacherList",s_id:$("#s_id").val()},
        		dataType:"json",
        		success:function(res)
        		{
        			var termList=res;
        			
        			for(var i=0;i<termList.length;i++)
        			{
        				var option=$("<option value="+termList[i].id+">"+termList[i].name+"</option>");
        				option.appendTo($("#t_id"));
        			}
        		}
        		
        	});
        }
        function getCheckCode()
        {
        	$.ajax({
        		type:"GET",
        		url:"http://192.168.20.194:8080/sysedu/teacher",
        		data:{type:"getCheckCode"},
        		success:function(res)
        		{
        			var src="http://192.168.20.194:8080/sysedu/teacher?type=getCheckCode&random="+(Math.random()*100);
        			alert(src);
        			$("#c_id").attr("src",src);
        		}
        		
        	});
        }
        function getCourse()
        {
        	
        	$.ajax({
        		type:"GET",
        		url:"http://192.168.20.194:8080/sysedu/teacher",
        		data:{type:"getCourse",s_id:$("#s_id").val(),t_id:$("#t_id").val(),checkCode:$("#check_code").val()},
        		dataType:"json",
        		success:function(res)
        		{
        			alert(JSON.stringify(res));
        			 createTable(res);
        		}
        		
        	});
        }
        function createTable(res){
        /* 	$("#userList").text(""); */
            var courses=res.courses;
            alert(courses.length);
           /*  var head= $("<tr><td></td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td> <td>星期五</td><td>星期六</td> <td>星期日</td></tr>"); */
            var head=$("<tr>");
           head.appendTo($("#userList"));
            for(var j=0;j<5;j++)
           	{
            	
           		
              var tr=$("<tr>");
            /* if(j==0)
          	{
          		tr.append("<td rowspan=\"2\">").text("上午");
          	}
            else if(j==2)
            {
            	tr.append("<td rowspan=\"2\">").text("下午");
            }
            else if(j==4)
            {
            	tr.append("<td>").text("晚上");
            }
            else
            {
            	 tr.append("<td>").text("\t"); 
            }
             for(var i=0;i<courses.length;i++)
             {
            	 	var user=courses[i].course;
            	 	tr.append($("<td>").text(user[j]));                    
             } */
             
             
             if(j==0)
           	{
           		tr.append("<td").text("上午");
           	}
             else if(j==1)
             {
             	tr.append("<td>").text(".");
             }
             else if(j==2)
             {
             	tr.append("<td>").text("下午");
             }
             else if(j==3)
             {
             	tr.append("<td>").text(".");
             }
             else if(j==4)
             {
             	tr.append("<td>").text("晚上");
             }
            
            
              for(var i=0;i<courses.length;i++)
              {
             	 	var user=courses[i].course;
             	 	tr.append($("<td>").text(user[j]));                    
              }
                tr.appendTo($("#userList"));
               
            } 
        }  
                  
      
       
    });
</script>
        
        



    <!--     Fonts and icons     -->
    <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
    <link href="assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
</head>
<body>
<div class="wrapper">
    <div class="sidebar" data-color="purple" data-image="assets/img/sidebar-5.jpg">

    <!--

        Tip 1: you can change the color of the sidebar using: data-color="blue | azure | green | orange | red | purple"
        Tip 2: you can also add an image using data-image tag

    -->

    	<div class="sidebar-wrapper">
            <div class="logo">
                <a href="#" class="simple-text">
                   教务系统
                </a>
            </div>

            <ul class="nav">
                <li >
                    <a href="course.html">
                        <i class="pe-7s-graph"></i>
                        <p>课程课表</p>
                    </a>
                </li>
                <li>
                    <a href="teacher.html" class="active">
                        <i class="pe-7s-user"></i>
                        <p>教师课表</p>
                    </a>
                </li>
                <li>
                    <a href="class.html">
                        <i class="pe-7s-note2"></i>
                        <p>班级课表</p>
                    </a>
                </li>
                <li>
                    <a href="classroom.html">
                        <i class="pe-7s-news-paper"></i>
                        <p>教室课表</p>
                    </a>
                </li>
                
				<li class="active-pro">
                    <a href="upgrade.html">
                        <i class="pe-7s-rocket"></i>
                        <p>welcome you!</p>
                    </a>
                </li>
            </ul>
    	</div>
    </div>

    <div class="main-panel">
        <nav class="navbar navbar-default navbar-fixed">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a href="#" class="navbar-brand">教师课表</a>
                </div>
              
                <div class="collapse navbar-collapse">
              
                    <ul class="nav navbar-nav navbar-right">
                        
                       <li style="margin-top:15px;">
                            
                                	    学期学年:
                                  <select id="s_id" name="s_id" style='WIDTH:200px'>
                           
							         </select>
                             
                              <!-- <ul class="dropdown-menu" id="t_id" name="t_id">
                                <li ><a href="#"></a></li>
                               </ul> -->
                        </li>
                       <li style="margin-top:15px;">
                            
                                	  &nbsp;&nbsp;  教师:
                                  <select id="t_id" name="t_id" style='WIDTH:145px'>
                                  
							         </select>
                             
                             
                        </li>
                        <li style="margin-top:15px;">
                            
                           	    &nbsp;&nbsp;验证码:<input type="text" name="Check_Code" id="check_code" style="width:50px;height:25px">

                           
                       <img id="c_id" src="" style="width:50px;height:25px"/>
                           <button id="show">
                                <i  class="fa fa-search" ></i>
                            </button>
                        </li>
                       
                    </ul>
                   
                </div>
            </div>
        </nav>


         <div class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="header" style="center"  id="divcss5">
                                <h4 class="title" >青果软件学院教师课表</h4>
                                <p class="category" id="s_id" name="s_id">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
                            </div>
                      
                           <div class="content table-responsive table-full-width">
                                <table class="table  table-bordered " id="userList" border="1">
 
                                    <thead>
                                        <tr>
                                        
                                        <th width="9%"></th>
                                        <th width="13%">星期一</th>
                                        <th width="13%">星期二</th>
                                        <th width="13%">星期三</th>
                                        <th width="13%">星期四</th>
                                        <th width="13%">星期五</th>
                                        <th width="13%">星期六</th>
                                        <th width="13%">星期日</th>
                                    </tr>
                                    </thead>
                                   
                                </table>

                            </div>
                        </div> 
                        </div>
                    </div>


                   


                </div>
            </div>
        </div>

      

    </div>
</div>

</body>

        <!--   Core JS Files   -->
    <!-- <script src="assets/js/jquery-1.10.2.js" type="text/javascript"></script> -->
	<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>

	<!--  Checkbox, Radio & Switch Plugins -->
	<script src="assets/js/bootstrap-checkbox-radio-switch.js"></script>

	<!--  Charts Plugin -->
	<script src="assets/js/chartist.min.js"></script>

    <!--  Notifications Plugin    -->
    <script src="assets/js/bootstrap-notify.js"></script>

    <!--  Google Maps Plugin    -->
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>

    <!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
	<script src="assets/js/light-bootstrap-dashboard.js"></script>

	<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
	<script src="assets/js/demo.js"></script>

</html>
